#include "cifar10dialog.h"
#include "cifar10app.h"

#include <QApplication>

#include <erpc_client_setup.h>
#include <erpc_port.h>
#include "c_cifar10_client.h"

#define USE_TCP_TRANSPORT

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication a(argc, argv);
    int ret;

#ifdef USE_TCP_TRANSPORT
    erpc_transport_t transport = erpc_transport_tcp_init(CIFAR10_HOST, CIFAR10_PORT, false);
#else
    erpc_transport_t transport = erpc_transport_serial_init("COM6", 115200);
#endif
    if (transport == NULL) {
        printf("erpc transport init error\n");
        return 0;
    }
    erpc_mbf_t message_buffer_factory = erpc_mbf_dynamic_init();
    erpc_client_t client = erpc_client_init(transport, message_buffer_factory);
    if (client == NULL) {
        printf("erpc client init error\n");
        return 0;
    }
    initCifar10_client(client);

    Cifar10Dialog w;
    w.show();

    ret = a.exec();

    deinitCifar10_client();
#ifdef USE_TCP_TRANSPORT
    erpc_transport_tcp_close(transport);
#else
#endif
  return ret;
}
